
/*mysql初始化*/

var mysql = require("mysql");
var async = require('async');
let db = require("../config/db");
//设置数据库编码格式
db.mysql.charset = 'utf8mb4';
var {
    setErrorLog
} = require("../middleware/setLog");
module.exports = mysqlLoader = () => {
    return new Promise((resolve, reject) => {
        const mysqlPool = mysql.createPool(db.mysql)
        mysqlPool.getConnection(function (err, connection) {
            if (err) {
                setErrorLog(`mysql连接异常 错误信息： ${JSON.stringify(err)})`);
                reject(err);
            }
            else {
                resolve(mysqlPool);
            }
        })
    })
}